package com.financing.wap.dao.impl;

import java.math.BigDecimal;
import java.sql.SQLException;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Repository;

import com.financing.wap.common.SqlName;
import com.financing.wap.dao.IYouDanAmountDao;
import com.financing.wap.dto.YouDanAmountDTO;
import com.financing.wap.vo.YouDanAmountVO;


@Repository("youDanAmountDaoImpl")
public class YouDanAmountDaoImpl extends BaseDaoImpl implements IYouDanAmountDao {
	
	@Override
	public Class getEntityClass() {
		return null;
	}

	@Override
	public Integer insertYouDanAmount(YouDanAmountDTO youDanAmountDTO) throws SQLException {
		return (Integer) this.sqlMapClientTemplate.insert(SqlName.insertYouDanAmount,youDanAmountDTO);
	}

	@Override
	public int updateYouDanAmount(YouDanAmountDTO youDanAmount) throws SQLException {
		return this.sqlMapClientTemplate.update(SqlName.updateYouDanAmount, youDanAmount);
	}

	@Override
	public List<YouDanAmountDTO> getYouDanAmount(YouDanAmountVO youDanAmount) throws SQLException {
		return (List<YouDanAmountDTO>) this.sqlMapClientTemplate.queryForList(SqlName.getYouDanAmount, youDanAmount);
	}

	@Override
	public BigDecimal getBaoZhengJinAmount(Map<String, Object> map) {
		BigDecimal r = (BigDecimal)this.sqlMapClientTemplate.queryForObject(SqlName.getBaoZhengJinAmount, map);
		if(null == r){
			return new BigDecimal(0);
		}else{
			return r;
		}
	}

	@Override
	public BigDecimal getCommissionAmount(Map<String, Object> map) {
		BigDecimal r = (BigDecimal) this.sqlMapClientTemplate.queryForObject(SqlName.getCommissionAmount, map);
		if(null == r){
			return new BigDecimal(0);
		}else{
			return r;
		}
	}

	@Override
	public Integer getYouDanAmountCount(YouDanAmountVO youDanAmount) throws SQLException {
		return (Integer) this.sqlMapClientTemplate.queryForObject(SqlName.getYouDanAmountCount, youDanAmount);
	}
}
